package ru.study.thinkin.chapter10.fabricSquadron;

public class CallFunction {
	private Character[] squadron ;
	
	public void createSquadron(SquadronFactory factory,int volume) {
		squadron = new Character[volume];		
				
		squadron[0] = factory.createWarrior();
		squadron[1] = factory.createMage();
		squadron[2] = factory.createArcher();		
		
		fire(squadron);
	}
	
	public void fire (Character[] squadron ) {
		for(int i=0 ; i< squadron.length;i++) {
			if (squadron[i] != null) {
				squadron[i].attack();
			}	
		}
	}	
	
	public static void main(String[] args) {
		CallFunction cf = new CallFunction();
		System.out.println("start");
		cf.createSquadron(new ElfSquadronFactory(),3);
		cf.createSquadron(new OrcSquadronFactory(),3);
		
	}

}
